home *** CD-ROM | disk | FTP | other *** search
/ Champak 61 / Volume 61 - JOGO DISK .iso / Games / hello_kitty.swf / scripts / frame_67 / DoAction.as
Text File  |  2008-03-13  |  13KB  |  479 lines

  1. stop();
  2. _global.PHPObject = function()
  3. {
  4.    var _loc1_ = this;
  5.    _loc1_._data = [];
  6.    _loc1_.init.apply(_loc1_,arguments);
  7. };
  8. PHPObject.prototype = new Object();
  9. PHPObject.prototype.init = function()
  10. {
  11.    var _loc1_ = this;
  12.    var _loc2_ = arguments;
  13.    _loc1_._loader = new PHPLoader();
  14.    _loc1_._data = [0,"",[],[],_loc1_._data[4] != undefined ? _loc1_._data[4] : ""];
  15.    if(_loc2_)
  16.    {
  17.       svc = _loc2_[0].toString();
  18.       if(svc.indexOf("http://") != -1 || svc.indexOf("https://") != -1)
  19.       {
  20.          _loc1_._data[1] = "WebServiceProxy";
  21.          _loc1_.wsdlLoc = svc;
  22.          _loc1_.params = [];
  23.       }
  24.       else
  25.       {
  26.          _loc1_._data[1] = svc;
  27.          if(_loc2_[1].length)
  28.          {
  29.             _loc1_._loader.gateway = _loc2_[1].toString();
  30.          }
  31.          if(_loc2_[2])
  32.          {
  33.             _loc1_._data[7] = 1;
  34.          }
  35.          if(_loc2_[3].length)
  36.          {
  37.             _loc1_._data[8] = _loc2_[3];
  38.          }
  39.       }
  40.       if(_loc1_._data[1] != undefined)
  41.       {
  42.          _loc1_[_loc1_._data[1]]();
  43.       }
  44.    }
  45. };
  46. PHPObject.prototype.onAbort = function()
  47. {
  48. };
  49. PHPObject.prototype.onError = function(error)
  50. {
  51.    trace(error);
  52. };
  53. PHPObject.prototype.onInit = function()
  54. {
  55. };
  56. PHPObject.prototype.onResult = function()
  57. {
  58. };
  59. PHPObject.prototype.abortExecute = function()
  60. {
  61.    var _loc1_ = this;
  62.    if(_loc1_._loader.isBusy)
  63.    {
  64.       _loc1_._loader.id = _loc1_._loader.id + 1;
  65.       _loc1_._loader.isBusy = false;
  66.       _loc1_._loader.refObj.onAbort();
  67.    }
  68. };
  69. PHPObject.prototype.delayExecute = function()
  70. {
  71.    this._loader.delay = true;
  72. };
  73. PHPObject.prototype.execute = function()
  74. {
  75.    var _loc1_ = this;
  76.    if(_loc1_._loader.delay == true)
  77.    {
  78.       _loc1_._loader.delay = false;
  79.       _loc1_.__connect(_loc1_._data[2][_loc1_._data[2].length - 1]);
  80.    }
  81. };
  82. PHPObject.prototype.getBytesLoaded = function()
  83. {
  84.    if(this._loader.isBusy)
  85.    {
  86.       return this._loader.getBytesLoaded();
  87.    }
  88.    return false;
  89. };
  90. PHPObject.prototype.getBytesTotal = function()
  91. {
  92.    if(this._loader.isBusy)
  93.    {
  94.       return this._loader.getBytesTotal();
  95.    }
  96.    return false;
  97. };
  98. PHPObject.prototype.getOutput = function()
  99. {
  100.    return this._loader.output;
  101. };
  102. PHPObject.prototype.setCredentials = function()
  103. {
  104.    this._data[5] = arguments;
  105. };
  106. PHPObject.prototype.setDefaultGatewayKey = function(key)
  107. {
  108.    _global.defaultGatewayKey = key;
  109. };
  110. PHPObject.prototype.setDefaultGatewayUrl = function(url)
  111. {
  112.    _global.defaultGatewayUrl = url;
  113. };
  114. PHPObject.prototype.setGateway = function(url)
  115. {
  116.    this._loader.gateway = url;
  117. };
  118. PHPObject.prototype.setKey = function(key)
  119. {
  120.    this._data[4] = key;
  121. };
  122. PHPObject.prototype.setService = function(svc)
  123. {
  124.    this._data[1] = svc;
  125. };
  126. PHPObject.prototype.utf8encode = function(flag)
  127. {
  128.    this._data[6] = flag;
  129. };
  130. PHPObject.prototype.__resolve = function(method)
  131. {
  132.    var _loc1_ = this;
  133.    var _loc2_ = arguments;
  134.    if(method.indexOf("_onResult") != -1)
  135.    {
  136.       return _loc1_.onResult(_loc1_._loader.serverResult);
  137.    }
  138.    if(method.indexOf("_onError") != -1)
  139.    {
  140.       return _loc1_.onResult(_loc1_._loader.serverResult);
  141.    }
  142.    var methodExists = true;
  143.    if(typeof method != "number" && _loc1_._loader.classMethods[_loc1_._data[1]] && _loc1_._data[1] != "WebServiceProxy")
  144.    {
  145.       if(_loc1_._loader.classMethods[method.toLowerCase()] == undefined)
  146.       {
  147.          methodExists = false;
  148.       }
  149.    }
  150.    if(methodExists)
  151.    {
  152.       return function()
  153.       {
  154.          var _loc1_ = arguments;
  155.          var _loc2_ = this;
  156.          if(!_loc2_._loader.isBusy || _loc2_._loader.delay)
  157.          {
  158.             if(_loc2_._data[1] == "WebServiceProxy" && method != "call" && method != "WebServiceProxy")
  159.             {
  160.                var operation = method;
  161.                var _loc3_ = [];
  162.                var x = _loc1_.length;
  163.                i = 0;
  164.                while(i < x)
  165.                {
  166.                   _loc3_[_loc1_[i]] = _loc1_[i + 1];
  167.                   i += 2;
  168.                }
  169.                return _loc2_.call(operation,_loc3_);
  170.             }
  171.             if(method != undefined && method != _loc2_._data[1])
  172.             {
  173.                var m = !(typeof method == "number" || !_loc2_._loader.classMethods[_loc2_._data[1]]) ? _loc2_._loader.classMethods[method] : method;
  174.                _loc2_._data[2].push(m);
  175.                _loc2_._data[3].push(_loc1_);
  176.             }
  177.             if(_loc2_._loader.delay)
  178.             {
  179.                return true;
  180.             }
  181.             _loc2_.__connect(method);
  182.          }
  183.          return false;
  184.       };
  185.    }
  186.    _loc1_.onError("Error - Method " + method + " does not exist");
  187.    return undefined;
  188. };
  189. PHPObject.prototype.__connect = function(method)
  190. {
  191.    var _loc1_ = this;
  192.    var _loc2_ = method;
  193.    _loc1_._loader.gateway = _loc1_._loader.gateway != "" ? _loc1_._loader.gateway : _global.defaultGatewayUrl;
  194.    if(_loc1_._loader.gateway.length)
  195.    {
  196.       _loc1_._loader.refObj = _loc1_;
  197.       _loc1_._data[4] = _loc1_._data[4] != "" ? _loc1_._data[4] : _global.defaultGatewayKey;
  198.       _loc1_._data[0] = _loc1_._loader.id;
  199.       var obj = _loc1_._loader._pack(_loc1_);
  200.       _loc1_._loader._send(obj,_loc2_);
  201.       _loc1_._data[2] = [];
  202.       _loc1_._data[3] = [];
  203.       if(typeof _loc2_ == "number")
  204.       {
  205.          for(var _loc3_ in _loc1_._loader.classMethods)
  206.          {
  207.             if(_loc1_._loader.classMethods[_loc3_] == _loc2_)
  208.             {
  209.                _loc2_ = _loc3_;
  210.                break;
  211.             }
  212.          }
  213.       }
  214.       _loc1_._loader.lastMethod = _loc2_;
  215.       return true;
  216.    }
  217. };
  218. _global.PHPLoader = function()
  219. {
  220.    this.init();
  221. };
  222. PHPLoader.prototype = new LoadVars();
  223. PHPLoader.prototype.init = function()
  224. {
  225.    var _loc1_ = this;
  226.    _loc1_.classMethods = [];
  227.    _loc1_.delay = false;
  228.    _loc1_.gateway = "";
  229.    _loc1_.id = 0;
  230.    _loc1_.isBusy = false;
  231.    _loc1_.refObj = "";
  232. };
  233. PHPLoader.prototype.onData = function(src)
  234. {
  235.    var _loc2_ = src;
  236.    var _loc1_ = _loc2_.substr(0,_loc2_.indexOf("O"));
  237.    if(_loc1_ == this.id || _loc1_ == 0)
  238.    {
  239.       this._parse(_loc2_.substr(_loc1_.length),_loc1_);
  240.    }
  241. };
  242. PHPLoader.prototype._parse = function(src, id)
  243. {
  244.    var _loc1_ = this;
  245.    var _loc2_ = src;
  246.    _global.dlSize = _loc2_.length;
  247.    _loc1_.isBusy = false;
  248.    _loc2_ = Serializer.unserialize(_loc2_);
  249.    _loc1_._unpack(_loc2_,_loc1_.refObj);
  250.    if(_loc1_.serverError.length)
  251.    {
  252.       _loc1_.refObj.onError(_loc1_.serverError);
  253.    }
  254.    else if(id == 0)
  255.    {
  256.       _loc1_.refObj.onInit();
  257.    }
  258.    else
  259.    {
  260.       _loc1_.refObj[_loc1_.lastMethod + "_onResult"](_loc1_.serverResult);
  261.    }
  262. };
  263. PHPLoader.prototype._unpack = function(src, dest)
  264. {
  265.    var _loc1_ = dest;
  266.    var _loc2_ = src;
  267.    for(var i in _loc2_)
  268.    {
  269.       if(i == "_loader")
  270.       {
  271.          for(var _loc3_ in _loc2_[i])
  272.          {
  273.             _loc1_[i][_loc3_] = _loc2_[i][_loc3_];
  274.             if(_loc3_ == "classMethods")
  275.             {
  276.                _loc1_[i][_loc3_][_loc1_._data[1]] = true;
  277.             }
  278.          }
  279.       }
  280.       else
  281.       {
  282.          _loc1_[i] = _loc2_[i];
  283.       }
  284.    }
  285. };
  286. PHPLoader.prototype._pack = function(obj)
  287. {
  288.    var _loc1_ = obj;
  289.    var _loc2_ = new Object();
  290.    for(var _loc3_ in _loc1_)
  291.    {
  292.       if(_loc3_ != "_loader" && typeof _loc1_[_loc3_] != "function")
  293.       {
  294.          _loc2_[_loc3_] = _loc1_[_loc3_];
  295.       }
  296.    }
  297.    return _loc2_;
  298. };
  299. PHPLoader.prototype._send = function(obj, methodName)
  300. {
  301.    var _loc1_ = this;
  302.    s = new XML(Serializer.serialize(obj));
  303.    s.contentType = "text/plain";
  304.    s.sendAndLoad(_loc1_.gateway,_loc1_,"POST");
  305.    if(obj._data[1] != methodName)
  306.    {
  307.       _loc1_.isBusy = true;
  308.    }
  309.    else
  310.    {
  311.       _loc1_.id = _loc1_.id + 1;
  312.    }
  313.    _global.ulSize = s.toString().length;
  314. };
  315. _global.Serializer = function()
  316. {
  317. };
  318. Serializer.prototype.unserialize = function($string, debug)
  319. {
  320.    return this.$_getValue($string)[0];
  321. };
  322. Serializer.prototype.$_getNext = function($string)
  323. {
  324.    var _loc1_ = $string;
  325.    var _loc2_ = undefined;
  326.    var _loc3_ = undefined;
  327.    _loc2_ = this.$_getValue(_loc1_);
  328.    _loc1_ = _loc2_[1];
  329.    _loc3_ = this.$_getValue(_loc1_);
  330.    _loc1_ = _loc3_[1];
  331.    return [_loc2_[0],_loc3_[0],_loc1_];
  332. };
  333. Serializer.prototype.$_getValue = function($string)
  334. {
  335.    var _loc1_ = $string;
  336.    var type;
  337.    var _loc3_ = undefined;
  338.    var a;
  339.    var b;
  340.    type = _loc1_.charAt(0);
  341.    switch(type)
  342.    {
  343.       case "s":
  344.          _loc3_ = _loc1_.substr(2,_loc1_.indexOf(":",3) - 2) * 1;
  345.          a = _loc1_.substr(length(_loc3_) + 4,_loc3_).toString();
  346.          a = unescape(a);
  347.          break;
  348.       case "i":
  349.          _loc3_ = _loc1_.substr(2,_loc1_.indexOf(";",3) - 2) * 1;
  350.          a = parseInt(_loc3_);
  351.          break;
  352.       case "d":
  353.          _loc3_ = _loc1_.substr(2,_loc1_.indexOf(";",3) - 2) * 1;
  354.          a = parseFloat(_loc3_);
  355.          break;
  356.       case "b":
  357.          _loc3_ = _loc1_.substr(2,_loc1_.indexOf(";",3) - 2) * 1;
  358.          a = !(_loc3_ == "true" || _loc3_ == "1") ? false : true;
  359.          break;
  360.       case "N":
  361.          a = null;
  362.          _loc3_ = "";
  363.          _loc1_ = _loc1_.substr(1);
  364.          break;
  365.       default:
  366.          break;
  367.       case "a":
  368.       case "O":
  369.          var delim1 = _loc1_.indexOf(":",_loc1_.indexOf(":") + 1) + 2;
  370.          _loc3_ = _loc1_.substr(2,_loc1_.indexOf(":",3) - 2) * 1;
  371.          if(type == "a")
  372.          {
  373.             a = new Array();
  374.             _loc1_ = _loc1_.substr(_loc1_.indexOf(_loc3_));
  375.          }
  376.          else
  377.          {
  378.             a = new Object();
  379.             _loc1_ = _loc1_.substr(length(_loc1_.substr(length(_loc3_) + 4,_loc3_)) + _loc1_.indexOf(_loc1_.substr(length(_loc3_) + 4,_loc3_)) + 2);
  380.          }
  381.          var objectLength = _loc1_.substr(0,_loc1_.indexOf(":")) * 1;
  382.          var counter = 0;
  383.          _loc1_ = _loc1_.substr(_loc1_.indexOf(":") + 2);
  384.          while(counter < objectLength)
  385.          {
  386.             var _loc2_ = this.$_getNext(_loc1_);
  387.             _loc1_ = _loc2_[2];
  388.             a[_loc2_[0]] = _loc2_[1];
  389.             counter++;
  390.          }
  391.          return [a,_loc1_.substr(_loc1_.indexOf("}") + 1)];
  392.    }
  393.    if(type != "s")
  394.    {
  395.       _loc3_ = length(_loc3_);
  396.    }
  397.    _loc1_ = _loc1_.substr(_loc1_.indexOf(";",_loc3_) + 1);
  398.    return [a,_loc1_];
  399. };
  400. Serializer.prototype.serialize = function(v)
  401. {
  402.    return escape(this.$_parseValue(v));
  403. };
  404. Serializer.prototype.$_parseValue = function(v)
  405. {
  406.    var _loc1_ = v;
  407.    switch(_loc1_.__proto__)
  408.    {
  409.       case Array.prototype:
  410.       case Object.prototype:
  411.       case MovieClip.prototype:
  412.          var counter = 0;
  413.          var arrayValue = "";
  414.          for(var a in _loc1_)
  415.          {
  416.             if(_loc1_[a].__proto__ != Function.prototype)
  417.             {
  418.                var _loc2_ = this.$_parseValue(a);
  419.                var _loc3_ = this.$_parseValue(_loc1_[a]);
  420.                arrayValue += _loc2_ add _loc3_;
  421.                counter++;
  422.             }
  423.          }
  424.          if(_loc1_.__proto__ == Array.prototype)
  425.          {
  426.             return "a:" + counter + ":{" + arrayValue + "}";
  427.          }
  428.          return "O:8:\"stdClass\":" + counter + ":{" + arrayValue + "}";
  429.          break;
  430.       case String.prototype:
  431.          if(this.enableMultiByte)
  432.          {
  433.             _loc1_ = escape(_loc1_);
  434.             break;
  435.          }
  436.          break;
  437.       case undefined:
  438.       case Date.prototype:
  439.          break;
  440.       case Number.prototype:
  441.          if(isNaN(_loc1_))
  442.          {
  443.             return "N;";
  444.          }
  445.          _loc1_ = Number(_loc1_);
  446.          if(_loc1_ % 1 == 0)
  447.          {
  448.             return "i:" + _loc1_ + ";";
  449.          }
  450.          return "d:" + _loc1_ + ";";
  451.          break;
  452.       case Boolean.prototype:
  453.          return "b:" + (_loc1_ != true ? 0 : 1) + ";";
  454.       default:
  455.    }
  456.    return "s:" + length(_loc1_) + ":\"" + _loc1_ + "\";";
  457. };
  458. _global.Serializer = new Serializer();
  459. _global.defaultGatewayKey = "secret";
  460. _global.defaultGatewayUrl = "server/gateway.php";
  461. w_obj = new PHPObject("write");
  462. myscore = _root.score;
  463. send_btn.onPress = function()
  464. {
  465.    if(myname == undefined or myname == "")
  466.    {
  467.       errormessage.gotoAndStop("firstname");
  468.    }
  469.    else if(myemail == undefined or myemail == "")
  470.    {
  471.       errormessage.gotoAndStop("email");
  472.    }
  473.    else if(myemail != undefined and myname != undefined)
  474.    {
  475.       w_obj.increase(myscore,myname,myemail,myage,mymobile);
  476.       play();
  477.    }
  478. };
  479.